
package com.neusoft.neu24g3.myioc;

import com.neusoft.neu24.nep.entity.Role;
import com.neusoft.neu24g3.myioc.entity.Dept;
import com.neusoft.neu24g3.myioc.service.DeptService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * MainApp 主类
 * Ioc/DI
 * @author Administrator
 * @version 2024/05/23 14:31
 **/
public class MainApp {
    public static void main(String[] args) {
        ApplicationContext context =new ClassPathXmlApplicationContext("spring.xml");


        DeptService deptService = (DeptService) context.getBean("deptService");
        deptService.f2();

//        Dept dept = (Dept) context.getBean("dept4");
//        System.out.println(dept);

    }

    public static void main2(String[] args) {
        ApplicationContext context =new ClassPathXmlApplicationContext("spring.xml");
        Role  role = (Role) context.getBean("role");
        System.out.println(role);

    }
    public static void main1(String[] args) {
//   Role  role =new Role();
//        IoC：控制反转（英语：Inversion of Control，缩写为IoC）
        Role  role =new Role();
        role.setId(1);
        System.out.println(role);
        role =null;
    }
}